package com.scala.oop.objectDemo

/**
 * Created by Administrator on 2018/1/27/027.
 *
 * 适用于全局只有一份
 *
 */

class Person(val name:String = "leo",val age:Int =22){
  println(" name: "+ name+" ,age: " + age + ",and sometimes your have "+ Person.eyeNum + " eyes")
}
object Person {

  println(" this is persion object! constructor is executing!")
  private var eyeNum = 2

  def getEyeNum = eyeNum

  //定义apply对象
   def apply(name:String) = new Person(name)


  def main(args: Array[String]) {
    var p = new Person

    Person.apply("zhenghui")
    Person("xiaozheng")
  }
}
